package com.monkeygroup.mygoplus.view.home.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.monkeygroup.mygoplus.R;

/**
 * Created by LCW on 2017/6/8.
 */

public class MapActivity extends AppCompatActivity implements OnMapReadyCallback {
    private String positon;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map_things_detail);

        SupportMapFragment mapFragment =
                (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_thing_detail);
        mapFragment.getMapAsync(this);
        positon = (String) getIntent().getBundleExtra("positon").getSerializable("positon");
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        String posions[] = positon.split("-");
        LatLng positon = new LatLng(Double.valueOf(posions[0]), Double.valueOf(posions[1]));
        googleMap.addMarker(new MarkerOptions().position(positon).title(""));
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(positon));
        googleMap.setBuildingsEnabled(true);
    }
}
